using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CMS.Core.DataInterfaces;
using CMS.Core.Domain;
using CMS.Data;
using AjaxPro;


namespace CMS.Presenters
{
    public class ChangePasswordPresenter
    {
        private IChangePasswordView View;
        private INguoiSuDungDao nsdDao;
        public ChangePasswordPresenter(IChangePasswordView View, INguoiSuDungDao nsdDao) {
            this.View = View;
            this.nsdDao = nsdDao;
        }

        public ChangePasswordPresenter()
        {
            this.nsdDao = new NguoiSuDungDao();
        }

        [AjaxMethod]
        public bool Ajax_Authentication(string username, string password)
        {
            if (nsdDao.CheckAuthentication(username, password))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public void UpdatePassWord(String ID, String pass)
        {
            NguoiSuDung nsd = this.nsdDao.GetById(ID);
            nsd.MatKhau = pass;
            this.nsdDao.Save(nsd);
        }
    }
}
